package org.dudemonkey.jvm.javawentidingwei.aboutlock;

import org.dudemonkey.jvm.concurrency.util.PrintUtil;

import java.util.Map;

public class SubWaitThread extends Thread {
    private Map slock = null;




    public SubWaitThread() {
//        this.slock=null;
    }

    public SubWaitThread( Map slock ) {
        this.slock=slock;
        super.setName("----------------SubWaitThread");
    }

    @Override
    public void run() {
        PrintUtil.print();
        synchronized (slock){
            for (int i = 0; i < 10 ; i++) {
                slock.put(this.getClass().getName()+i,"v:"+i);
            }

//            try {
//                slock.wait();
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }

            for (int i = 20; i < 30 ; i++) {
                slock.put(this.getClass().getName()+i,"v2 : "+i);
            }
        }

        PrintUtil.printContent(slock);
    }
}
